<template>
	<view class="list-view">
		<view class="top-bar"><uni-navbar :fixed="true" :back="true" color="#fff" title="会议活动"></uni-navbar></view>

		<view class="u-line"></view>
		<u-row class="link-box" gutter="0" align="top">
			<u-col span="3" v-if="$sysMenus('my_meeting_huiyi') || $sysMenus('hy_list')">
				<navigator hover-class="none" class="link-item" url="/pagesB/meeting/list?type=huiyi">
					<image src="/static/img/icon_13.png" mode="aspectFill"></image>
					所有会议
				</navigator>
			</u-col>
			<u-col span="3" v-if="$sysMenus('file_list')">
				<navigator hover-class="none" class="link-item" url="/pagesB/meeting/file">
					<image src="/static/img/icon_14.png" mode="aspectFill"></image>
					文档管理
				</navigator>
			</u-col>
			<u-col span="3" v-if="$sysMenus('my_meeting_jiebie')">
				<navigator hover-class="none" class="link-item" url="/pagesB/meeting/list?type=jiebie">
					<image src="/static/img/icon_15.png" mode="aspectFill"></image>
					界别活动
				</navigator>
			</u-col>
			<u-col span="3" v-if="$sysMenus('my_meeting_huodong') || $sysMenus('hd_list')">
				<navigator hover-class="none" class="link-item" url="/pagesB/meeting/list?type=huodong">
					<image src="/static/img/icon_16.png" mode="aspectFill"></image>
					所有活动
				</navigator>
			</u-col>
			<u-col span="3" v-if="$sysMenus('tongji_hy')">
				<navigator hover-class="none" class="link-item" url="/pagesB/meeting/statistics">
					<image src="/static/img/icon_89.png" mode="aspectFill"></image>
					统计分析
				</navigator>
			</u-col>
		</u-row>

		<!-- <view class="pro-inner" v-if="$sysMenus('my_meeting_huiyi')">
			<view class="h2-inner"><view class="h2-title">所有会议</view></view>
			<view>我的会议</view>
			<view class="pro-item"><u-line-progress :active-color="['#3DBBFF', '#3396FB']" :percent="100" :text="HNumAll"></u-line-progress></view>
			<view>报名中会议</view>
			<view class="pro-item"><u-line-progress :active-color="['#67FFDB', '#77DDC5']" :percent="parseInt((HNum1 / HNumAll) * 100)" :text="HNum1"></u-line-progress></view>
			<view>待开始会议</view>
			<view class="pro-item"><u-line-progress :active-color="['#FF7783', '#E80824']" :percent="parseInt((HNum2 / HNumAll) * 100)" :text="HNum2"></u-line-progress></view>
			<view>进行中会议</view>
			<view class="pro-item"><u-line-progress :active-color="['#FAD961', '#F76B1C']" :percent="parseInt((HNum3 / HNumAll) * 100)" :text="HNum3"></u-line-progress></view>
			<view>已结束会议</view>
			<view class="pro-item"><u-line-progress :active-color="['#C3C3C3', '#4C4C4C']" :percent="parseInt((HNum4 / HNumAll) * 100)" :text="HNum4"></u-line-progress></view>
		</view> -->

		<view class="plus-inner" v-if="$sysMenus('my_meeting_huiyi') || $sysMenus('hy_list')">
			<view class="h2-inner">
				<view class="h2-title">所有会议</view>
				<view>截止{{ timer | parseTime('{y}.{m}.{d} {h}:{i}') }}</view>
			</view>
			<view class="plus-box">
				<view class="plus-item bg92" @click="listTo('/pagesB/meeting/list')">
					<view class="title">{{ HNumAll }}</view>
					<view>我的会议</view>
				</view>
				<view class="plus-item bg93" @click="listTo('/pagesB/meeting/list?status=1')">
					<view class="title">{{ HNum1 }}</view>
					<view>报名中会议</view>
				</view>
				<view class="plus-item bg94" @click="listTo('/pagesB/meeting/list?status=2')">
					<view class="title">{{ HNum2 }}</view>
					<view>待开始会议</view>
				</view>
				<view class="plus-item bg95" @click="listTo('/pagesB/meeting/list?status=3')">
					<view class="title">{{ HNum3 }}</view>
					<view>进行中会议</view>
				</view>
				<view class="plus-item bg92" @click="listTo('/pagesB/meeting/list?status=4')">
					<view class="title">{{ HNum4 }}</view>
					<view>已结束会议</view>
				</view>
			</view>
		</view>

		<!-- <view class="pro-inner" v-if="$sysMenus('my_meeting_huodong')">
			<view class="h2-inner"><view class="h2-title">所有活动</view></view>
			<view>我的活动</view>
			<view class="pro-item"><u-line-progress :active-color="['#3DBBFF', '#3396FB']" :percent="100" :text="DNumAll"></u-line-progress></view>
			<view>报名中活动</view>
			<view class="pro-item"><u-line-progress :active-color="['#67FFDB', '#77DDC5']" :percent="parseInt((DNum1 / DNumAll) * 100)" :text="DNum1"></u-line-progress></view>
			<view>待开始活动</view>
			<view class="pro-item"><u-line-progress :active-color="['#FF7783', '#E80824']" :percent="parseInt((DNum2 / DNumAll) * 100)" :text="DNum2"></u-line-progress></view>
			<view>进行中活动</view>
			<view class="pro-item"><u-line-progress :active-color="['#FAD961', '#F76B1C']" :percent="parseInt((DNum3 / DNumAll) * 100)" :text="DNum3"></u-line-progress></view>
			<view>已结束活动</view>
			<view class="pro-item"><u-line-progress :active-color="['#C3C3C3', '#4C4C4C']" :percent="parseInt((DNum4 / DNumAll) * 100)" :text="DNum4"></u-line-progress></view>
		</view> -->

		<view class="plus-inner" v-if="$sysMenus('my_meeting_huodong') || $sysMenus('hd_list')">
			<view class="h2-inner">
				<view class="h2-title">所有活动</view>
				<view>截止{{ timer | parseTime('{y}.{m}.{d} {h}:{i}') }}</view>
			</view>
			<view class="plus-box">
				<view class="plus-item bg92" @click="listTo('/pagesB/meeting/list?type=huodong')">
					<view class="title">{{ DNumAll }}</view>
					<view>我的活动</view>
				</view>
				<view class="plus-item bg93" @click="listTo('/pagesB/meeting/list?type=huodong&status=1')">
					<view class="title">{{ DNum1 }}</view>
					<view>报名中活动</view>
				</view>
				<view class="plus-item bg94" @click="listTo('/pagesB/meeting/list?type=huodong&status=2')">
					<view class="title">{{ DNum2 }}</view>
					<view>待开始活动</view>
				</view>
				<view class="plus-item bg95" @click="listTo('/pagesB/meeting/list?type=huodong&status=3')">
					<view class="title">{{ DNum3 }}</view>
					<view>进行中活动</view>
				</view>
				<view class="plus-item bg92" @click="listTo('/pagesB/meeting/list?type=huodong&status=4')">
					<view class="title">{{ DNum4 }}</view>
					<view>已结束活动</view>
				</view>
			</view>
		</view>

		<view v-if="false && timer"></view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	data() {
		return {
			HNumAll: 0,
			HNum1: 0,
			HNum2: 0,
			HNum3: 0,
			HNum4: 0,
			HNum5: 0,
			DNumAll: 0,
			DNum1: 0,
			DNum2: 0,
			DNum3: 0,
			DNum4: 0,
			DNum5: 0,
			timer: ''
		};
	},
	onLoad() {
		this.loadLogin();
		this.loadHAll();
	},
	onPullDownRefresh() {
		this.loadHAll();
	},
	computed: {
		...mapState(['userInfo'])
	},
	methods: {
		loadLogin() {
			if (this.userInfo.Authorization) {
				this.clientCode = this.userInfo.sysUser.clientCode;
				this.userId = this.userInfo.sysUser.id;
				this.timer = new Date();
			} else {
				this.$logout();
			}
		},
		loadHAll() {
			let data = {
				clientCode: this.clientCode
			};
			let roleCodes = this.userInfo.roleCodes;
			let role = roleCodes.some((item) => {
				return item == 'bangongshi' || item == 'zhengxie' || item == 'hyhdap' || item == 'sys_manager';
			});
			if (!role) {
				data.userId = this.userId;
			}
			this.$request('/huiyihuodong/hyhd-meeting/meetingIndex', data).then((res) => {
				uni.stopPullDownRefresh();
				if (!res.data) {
					return false;
				}
				this.HNumAll = res.data.hyQuanbu;
				this.HNum1 = res.data.hyDaiqueren;
				this.HNum2 = res.data.hyDaikaishi;
				this.HNum3 = res.data.hyJinxingzhong;
				this.HNum4 = res.data.hyYijieshu;

				this.DNumAll = res.data.hdQuanbu;
				this.DNum1 = res.data.hdDaiqueren;
				this.DNum2 = res.data.hdDaikaishi;
				this.DNum3 = res.data.hdJinxingzhong;
				this.DNum4 = res.data.hdYijieshu;

				this.timer = new Date();
			});
		},
		listTo(url) {
			uni.navigateTo({
				url: url
			});
		}
	}
};
</script>

<style lang="scss">
.plus-box {
	.plus-item {
		padding-left: 116rpx;
		text-align: left;
	}
}
</style>
